/*
 * @Description: 生成版本号
 */
import { writeFile } from 'fs/promises'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'node:url'
import pkg from '../package.json' // need to be checked

function getVersion() {
  return pkg.version
}

const version = getVersion()

async function main() {
  // eslint-disable-next-line no-console
  console.log(`Gen Version: ${version}`)
  const thePath = dirname(fileURLToPath(import.meta.url))
  const outPath = resolve(thePath, '../packages/constants/version.ts')
  await writeFile(outPath, `export const version = '${version}'\n`)
}

main()
